package com.heima.wemedia.config;

import com.heima.wemedia.interceotpr.UserInterceptor;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Component
public class MvcConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        UserInterceptor userInterceptor = new UserInterceptor();
        registry.addInterceptor(userInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/login/in")
                .excludePathPatterns("/api/v1/wmuser/save")
                .excludePathPatterns("/api/v1/news_auth/list")
                .excludePathPatterns("/api/v1/news_auth/one/{id}")
                .excludePathPatterns("/api/v1/news_auth/auth_fail")
                .excludePathPatterns("/api/v1/news_auth/auth_pass")
        ;
    }
}
